import { hsqjInputJson, gdzczjJson } from "../data/hsqj-vk.js"
import { saasTosj } from "../../common.js"
import { fillInputDone } from "../../message.js"
function fillHspj(inputData) {
  try {
    let data = saasTosj(inputData, hsqjInputJson, gdzczjJson);
    // throw new Error("123123")
    Object.keys(data).forEach((item) => {
      let contents = $('form[name="form1"] .container .table-bordered').contents();
      let input = contents.find(`#${item}`).length !== 0 ? contents.find(`#${item}`) : contents.find(`[name='${item}']`);
      input.focus();
      input.val(parseFloat(data[item]).toFixed(2));
      input.blur();
    });
    fillInputDone({
      tax: 'hsqj',
      success: true,
      message: "汇算清缴-填报成功",
    })
  } catch (e) {
    console.log(e);
    fillInputDone({
      tax: 'hsqj',
      success: false,
      message: "汇算清缴-填报失败，请联系技术人员",
    })
  }

}

export { fillHspj }